#ifndef TIMEOUT_QUEUE_H
#define TIMEOUT_QUEUE_H

#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
#include <sys/epoll.h>

#include "struct_userOpInfo.h"

#define TIME_WHEEL_SIZE 30

typedef struct client_node{
    int netfd;
    time_t expireTime;//绝对过期时间
    struct client_node*next;
}clientNode_t;

typedef struct{
    clientNode_t *slots[TIME_WHEEL_SIZE];//时间轮数组
    int current_slot;//当前指针位置，check时向前移动
    time_t last_check_time;//上次检查的时间戳
}timeWheel_t;


void initTimeWheel(timeWheel_t *tw);
void addClient(timeWheel_t *tw,int netfd);
void updateClient(timeWheel_t *tw,int netfd);
void checkEcpiredClients(timeWheel_t *tw,int epfd);
void print_time_wheel(timeWheel_t *tw);


#endif
